#ifndef SERIALSERVER_H
#define SERIALSERVER_H

#include <QObject>
#include <functional>
#include "io/serialport.h"
#include <QMutex>
#include <QWaitCondition>
#include <QTimer>
#include "packetparser.h"

class SerialServer : public QObject
{
    Q_OBJECT
private:
    QString mPortName;
    SerialPort* mpSerialPort;
    PacketParser mParser;

public:
    explicit SerialServer(QString portName, QObject *parent = nullptr);
    virtual ~SerialServer();

    QString portName();

    void listen();
    void close();

    qint64 send(QByteArray bytes);

private:
    static void dump(QString tag, QByteArray& bytes);

signals:
    void received(QByteArray buff);
};

#endif // SERIALSERVER_H
